import socket
import os
from DesModule import des_encrypt, des_descrypt

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = "localhost"
port = 8000
Address = (host, port)
s.bind(Address)
s.listen()
conn, address = s.accept()
data = conn.recv(1024)
message = des_descrypt(data, "12345678")
print("从客户端接受到的数据为:", message)
if os.path.exists("server_send.txt"):
    file3 = open("server_send.txt", "a+")
else:
    file3 = open("server_send.txt", "w+")
file3.write("No matter how long the night,the day will come.")
file3.seek(0)
data2 = file3.readline()
send_to_client = des_encrypt(data2.encode(), "12345678")
conn.sendall(send_to_client.encode())
s.close()
